﻿@page
@model IndexModel
@{
    ViewData["Title"] = "Home page";
}
@section Scripts{
    <script>
        const eventSource = new EventSource("http://127.0.0.1:9111/msg/");
        eventSource.onmessage = function (event) { 
            if (event.data) {
                //document.getElementById('content').innerHTML += event.data ;
                const status = JSON.parse(event.data);
                document.getElementById('score1').innerHTML = status.score1;
                document.getElementById('score2').innerHTML = status.score2;
                if (status.lastaction) {
                    document.getElementById('content').innerHTML += status.lastaction;
                }
            }
        }
    </script>
}

<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <div style="font-size:40px">
        <p >
            <span id="score1">0</span>
            <span>-</span>
            <span id="score2">0</span>
        </p>
    </div>
    <div id="content" style="width:800px;height:600px;overflow:scroll;">
    </div>
</div>
